package design.pattern.factory.before;

/**
 * @author AtoVio, Winter Yuan
 */
public class CoffeeStore {

    public Coffee orderCoffee(CoffeeType type) {
        Coffee coffee;
        if (type == CoffeeType.AMERICAN) {
            coffee = new AmericanCoffee();
        } else if (type == CoffeeType.LATTE) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("对不起，没有对应类型咖啡");
        }

        // 加配料
        addThings(coffee);

        return coffee;
    }

    private void addThings(Coffee coffee) {
        coffee.addSugar();
        coffee.addMilk();
    }
}
